#include "Key.h"
#include "../../../SGD_Wrappers/CSGD_MessageSystem.h"
#include "../../../SGD_Wrappers/CSGD_Direct3D.h"
#include "../../../SGD_Wrappers/CSGD_EventSystem.h"
#include "../../DestroyEntityMessage.h"
CKey::CKey(void)
{
	m_bPickedUp = false;
	m_nItemType = 0;

	this->SetWidth( 20 );
	this->SetHeight(20);
}


CKey::~CKey(void)
{
}

void CKey::PickUp()
{

}

void CKey::HandleEvent(CEvent* pEvent)
{

}

void CKey::Render( void )
{
	CSGD_Direct3D::GetInstance()->DrawRect( GetRect(), 255, 0, 255 );

}

void CKey::Update(float fElapsedTime)
{
}

bool CKey::CheckCollision( IEntity* pOther)
{
	if( CEntity::CheckCollision( pOther ) )
	{
		if( pOther->GetType() == ENTITY_PLAYER )
		{
			CSGD_EventSystem::GetInstance()->SendEvent("PICK_UP",(void*)m_nItemType, nullptr, this);
			IMessage* i = new CDestroyEntityMessage( this );
			CSGD_MessageSystem::GetInstance()->SendMsg( i );
			i = nullptr;
			
			return true;
		}
	}
	return false;
}